package org.example.cardgame.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.example.cardgame.controller.PlayerWebSocket;
import org.example.cardgame.entity.Message;
import org.example.cardgame.entity.Player;

/**
 * @Author juanita.ren
 * @Date 2024/11/11 22:07
 * @Version 1.0
 */
public class PlayerHandle {
    public PlayerHandle() {
    }

    public static void sendMessage(Player player, Message message) {
        String msg = JSON.toJSONString(message, new SerializerFeature[]{SerializerFeature.DisableCircularReferenceDetect});
        PlayerWebSocket.sendMessageToPlayer(msg, player);
    }
}
